﻿@page "/scheduler/date-wise-grouping"

@using Syncfusion.Blazor.Schedule
@inherits SampleBaseComponent;

<SampleDescription>
    <p>   This demo illustrates the daily tasks of two employees grouped by date-wise.</p>
</SampleDescription>
<ActionDescription>
    <p>
        In this demo, there are 2 resources defined namely <strong>Alice</strong> and <strong>Smith</strong> under the resource
        <code>DataSource</code>. The Scheduler can be switched to group by date, by setting <code>true</code> to the option
        <code>ByDate</code> within the <code>Group</code> property.
    </p>
</ActionDescription>

<div class="control-section">
    <div class="content-wrapper">
        <SfSchedule TValue="ScheduleData.ResourceData" Width="100%" Height="650px" @bind-SelectedDate="@CurrentDate">
            <ScheduleGroup ByDate="true" Resources="@GroupData"></ScheduleGroup>
            <ScheduleResources>
                <ScheduleResource TItem="ResourceData" TValue="int[]" DataSource="@OwnersData" Field="TaskId" Title="Assignee" Name="Owners" TextField="Text" IdField="Id" ColorField="Color" AllowMultiple="true"></ScheduleResource>
            </ScheduleResources>
            <ScheduleViews>
                <ScheduleView Option="View.Day"></ScheduleView>
                <ScheduleView Option="View.Week"></ScheduleView>
                <ScheduleView MaxEventsPerRow="2" Option="View.Month"></ScheduleView>
                <ScheduleView Option="View.Agenda"></ScheduleView>
            </ScheduleViews>
            <ScheduleEventSettings DataSource="@DataSource">
                <ScheduleField>
                    <FieldSubject Name="Subject" Title="Task"></FieldSubject>
                    <FieldLocation Name="Location" Title="Project Name"></FieldLocation>
                    <FieldDescription Name="Description" Title="Comments"></FieldDescription>
                </ScheduleField>
            </ScheduleEventSettings>
        </SfSchedule>
    </div>
</div>

@code{
    private DateTime CurrentDate = new DateTime(2020, 1, 12);
    public List<ScheduleData.ResourceData> DataSource = new ScheduleData().GetResourceData();
    public string[] GroupData = new string[] { "Owners" };
    private List<ResourceData> OwnersData { get; set; } = new List<ResourceData> {
        new ResourceData { Text = "Alice", Id= 1, Color = "#df5286" },
        new ResourceData { Text = "Smith", Id= 2, Color = "#5978ee" }
    };
    public class ResourceData
    {
        public string Text { get; set; }
        public int Id { get; set; }
        public string Color { get; set; }
    }
}
